package com.chris.libs.example.common.inject;

import androidx.lifecycle.ViewModelProvider;

import com.chris.libs.example.R;
import com.chris.libs.base.x.mvpp.application.AppGlobal;
import com.chris.libs.example.model.DataItem;
import com.chris.libs.example.pages.ext.base.BaseExampleViewModel;
import com.chris.libs.example.pages.ext.recyclerview.RecyclerViewExampleViewModel;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Named;
import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;

/**
 * @author Chris chan
 * Create on： 2025/2/1 9:56
 * Use for:
 * Explain:
 */
@Module
public class AppModule {
    // 使用单例 创建全局ViewModel
    @Singleton
    @Provides
    public BaseExampleViewModel provideBaseExampleViewModel() {
        return new ViewModelProvider(AppGlobal.getOwner()).get(BaseExampleViewModel.class);
    }

    @Singleton
    @Provides
    public RecyclerViewExampleViewModel provideRecyclerViewExampleViewModel() {
        return new ViewModelProvider(AppGlobal.getOwner()).get(RecyclerViewExampleViewModel.class);
    }

    @Named("recyclerDataItemList")
    @Singleton
    @Provides
    public List<DataItem> provideRecyclerDataItemList() {
        List<DataItem> dataList = new ArrayList<>();
        dataList.add(new DataItem("天王盖地虎，宝塔镇河妖", R.drawable.ic_tab_main_home));
        dataList.add(new DataItem("宫廷玉液酒，一杯一百八", R.drawable.ic_tab_main_base_framework));
        dataList.add(new DataItem("踏破铁血无觅处，得来全不费工夫", R.drawable.ic_tab_main_widget));
        dataList.add(new DataItem("天王盖地虎，宝塔镇河妖", R.drawable.ic_tab_main_home));
        dataList.add(new DataItem("宫廷玉液酒，一百八一杯", R.drawable.ic_tab_main_base_framework));
        dataList.add(new DataItem("踏破铁血无觅处，得来全不费工夫", R.drawable.ic_tab_main_widget));
        dataList.add(new DataItem("天王盖地虎，宝塔镇河妖", R.drawable.ic_tab_main_home));
        dataList.add(new DataItem("宫廷玉液酒，一百八一杯", R.drawable.ic_tab_main_base_framework));
        dataList.add(new DataItem("踏破铁血无觅处，得来全不费工夫", R.drawable.ic_tab_main_widget));
        dataList.add(new DataItem("天王盖地虎，宝塔镇河妖", R.drawable.ic_tab_main_home));
        dataList.add(new DataItem("宫廷玉液酒，一百八一杯", R.drawable.ic_tab_main_base_framework));
        dataList.add(new DataItem("踏破铁血无觅处，得来全不费工夫", R.drawable.ic_tab_main_widget));
        dataList.add(new DataItem("天王盖地虎，宝塔镇河妖", R.drawable.ic_tab_main_home));
        dataList.add(new DataItem("宫廷玉液酒，一百八一杯", R.drawable.ic_tab_main_base_framework));
        dataList.add(new DataItem("踏破铁血无觅处，得来全不费工夫", R.drawable.ic_tab_main_widget));

        return dataList;
    }
}
